FROM centos:7.8.2003
MAINTAINER Chunge <wy521wywy@163.com>

RUN yum update -y && \
        yum clean all && \
        yum install -y http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpm epel-release net-tools && \
        yum install -y alsa-lib-devel autoconf automake bison broadvoice-devel bzip2 curl-devel e2fsprogs-devel flite-devel g722_1-devel gcc-c++ gdbm-devel gnutls-devel ilbc2-devel ldns-devel libcodec2-devel libcurl-devel libedit-devel libidn-devel libjpeg-devel libmemcached-devel libogg-devel libsilk-devel libsndfile-devel libtheora-devel libtiff-devel libtool libuuid-devel libvorbis-devel libxml2-devel lua-devel lzo-devel mongo-c-driver-devel ncurses-devel net-snmp-devel openssl-devel opus-devel pcre-devel perl perl-ExtUtils-Embed pkgconfig portaudio-devel postgresql-devel python-devel python-devel soundtouch-devel speex-devel sqlite-devel unbound-devel unixODBC-devel wget which yasm zlib-devel git libsysfs vim

WORKDIR /usr/local/
RUN git clone https://gitee.com/longchun4835/sofia-sip.git
WORKDIR /usr/local/sofia-sip/
RUN ./bootstrap.sh
RUN ./configure
RUN make && make install
RUN ldconfig

WORKDIR /usr/local/
RUN git clone https://gitee.com/longchun4835/libav.git
WORKDIR /usr/local/libav
RUN CFLAGS="-fPIC" ./configure --enable-pic --enable-shared
RUN make CXXFLAGS="fPIC"
RUN make install

WORKDIR /usr/local/
RUN git clone https://gitee.com/longchun4835/spandsp.git
WORKDIR /usr/local/spandsp/
RUN ./bootstrap.sh
RUN ./configure
RUN make && make install
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}
RUN ldconfig

WORKDIR /usr/local/src/

RUN git clone https://gitee.com/longchun4835/freeswitch.git
WORKDIR /usr/local/src/freeswitch/
RUN ./bootstrap.sh
RUN ./configure --enable-portable-binary \
            --prefix=/usr --localstatedir=/var --sysconfdir=/etc \
            --with-gnu-ld --with-python --with-openssl \
            --enable-core-odbc-support --enable-zrtp
ADD module/modules.conf /usr/local/src/freeswitch/modules.conf

RUN make && \
	make install && \
	make samples && \
	make cd-sounds-install && \
	make cd-moh-install && \
	ln -sf /usr/local/src/freeswitch/freeswitch /usr/bin/freeswitch && \
	ln -sf /usr/local/src/freeswitch/fs_cli /usr/bin/fs_cli

ADD module/event_socket.conf.xml /etc/freeswitch/autoload_configs/event_socket.conf.xml

EXPOSE 5060:5060/tcp 5060:5060/udp 5080:5080/tcp 5080:5080/udp
EXPOSE 5066/tcp 7443/tcp
EXPOSE 8021/tcp
EXPOSE 64535-65535/udp
EXPOSE 20000-24999:20000-24999/udp

CMD ["/bin/bash","freeswitch"]
